package org.wisdom.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.wisdom.entity.User;

@Mapper
public interface AuthMapper {

    @Select("select id, encoded_password from user where phone_number = #{phoneNumber}")
    User selectPasswordByPhoneNumber(String phoneNumber);

    @Select("select count(*) from user where phone_number = #{phoneNumber}")
    boolean selectPhoneNumberIsExist(String phoneNumber);

    @Insert("insert into user (id, phone_number, encoded_password, avatar_url, created_time) values (#{id}, #{phoneNumber}, #{encodedPassword}, #{avatarUrl}, #{createdTime})")
    void insertToRegister(User newUser);
}
